import request from '@/utils/request'
function getToken() {
  const token = localStorage.getItem('token')
  return token
}
// //商品审核
// export const getGoodsList = body => {
//   return request('ope/product/selectExaminePoroductList', {
//     method: 'POST',
//     body,
//   });
// };

//运营模板消息分页
export async function queryOpeOrderByCondition(params) {
  return request(`/hzsx/examineProduct/selectExaminePoroductList`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}
export async function selectExaminePoroductDirectBuyList(params) {
  return request(`/hzsx/examineProduct/selectExaminePoroductDirectBuyList`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}
export async function selectExamineProductEdit(params) {
  return request(
    `/hzsx/examineProduct/selectExamineProductEdit?productId=${params.productId}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}
export async function selectExamineProductDirectBuyEdit(params) {
  return request(
    `/hzsx/examineProduct/selectExamineProductDirectBuyEdit?productId=${params.productId}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}
export async function findCategories(params) {
  return request(`/hzsx/examineProduct/findCategories`, {
    method: 'get',
    data: params,
    headers: { token: getToken() }
  })
}
export async function selectExamineProductDetail(params) {
  return request(
    `/hzsx/examineProduct/selectExamineProductDetail?productId=${params.productId}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}
export async function selectExamineProductDirectDetail(params) {
  return request(
    `/hzsx/examineProduct/selectExamineProductDirectDetail?productId=${params.productId}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}

export async function examineProductConfirm(params) {
  return request(
    `/hzsx/examineProduct/examineProductConfirm?auditState=${params.auditState}&id=${params.id}&reason=${params.reason}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}
export async function examineProductDirectBuyConfirm(params) {
  return request(
    `/hzsx/examineProduct/examineProductDirectBuyConfirm?auditState=${
      params.auditState
    }&id=${params.id}&reason=${params.reason ? params.reason : ''}`,
    {
      method: 'get',
      data: params,
      headers: { token: getToken() }
    }
  )
}
export async function updateExamineProduct(params) {
  return request(`/hzsx/examineProduct/updateExamineProduct`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}

export async function updateExamineProductDirectBuy(params) {
  return request(`/hzsx/examineProduct/updateExamineProductDirectBuy`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
}
//商品编辑
export const getGoodsEdit = body =>
  request(`ope/product/selectExamineProductEdit?productId=${body.productId}`, {
    methods: 'GET'
  })
//商品编辑类目
export const editCategory = body =>
  request(`ope/product/findCategories`, { method: 'GET' })

//商品详情
export const getGoodsInfo = body =>
  request(`ope/product/selectExamineProductDetail?productId=${body}`, {
    method: 'GET'
  })

//编辑类目
export const getSelectAll = body =>
  request('ope/category/selectAll', { method: 'GET' })

//改变类目
export const handleChangSelect = body =>
  request(
    `ope/product/editFrontCategory?categoryId=${body.categoryId}&productId=${body.productId}`,
    { method: 'GET' }
  )

//改变审核状态
export const changStatus = body =>
  request(
    `ope/product/examineProductConfirm?id=${body.id}&auditState=${body.auditState}&reason=${body.reason}`,
    { method: 'GET' }
  )

//编辑商品
export const updateGoods = body =>
  request(`ope/product/updateExamineProduct`, {
    method: 'POST',
    body
  })

//获取提交审核的人员信息
export const getHistoryPost = params =>
  request(`/hzsx/examineProduct/commoditySubmission`, {
    method: 'POST',
    data: params,
    headers: { token: getToken() }
  })
